﻿using System;

namespace NDBGen.Descriptors.Columns.Tokens
{
    [ColumnTokenDescriptor(HasValue = true)]
    public sealed class DefaultValueTokenDescriptor : ColumnTokenDescriptorBase, IOrderedMetadata
    {
        public DefaultValueTokenDescriptor() { }

        public DefaultValueTokenDescriptor(Table table, String columnName, String foreignKeyReference)
            : base(table, columnName, foreignKeyReference) { }

        private const String TOSTRING_FORMAT = "{0}{1}";

        protected override Char Token { get { return '='; } }

        Int32 IOrderedMetadata.GenerationIndex { get { return 1; } }

        public override String ToString()
        {            
            return this.InitCalled ? String.Format(TOSTRING_FORMAT, this.Token, this.TokenValue) : this.Token.ToString();
        }
    }
}